<?php
require_once('config.php');

class connect{
    var $conn;       

    function connect(){
        $this->conn = mysql_connect(HOST_NAME, USER_NAME, PASSWORD);
        if(!isset($this->conn)) mysql_error();
        $db = mysql_select_db(DATABASE_NAME);
    }
    function disconnect(){
        mysql_close($this->conn);
    }
    
}


class database extends connect {
    var $result;
    
    function database($query){
        $this->connect();
        $this->result = mysql_query($query);    
        $this->disconnect();    
    }
    function num_row(){
        return mysql_numrows($this->result);
    }
    function render(){
        $arr_return = array();
        while($row = mysql_fetch_assoc($this->result)){
            $arr_return[] = $row;
        }
        return $arr_return;
    }
    function render_pro_info(){
        $arr_return = array();
        $i = 0;
        while($row = mysql_fetch_assoc($this->result)){
            $arr_return['item'.$i] = $row;
            $i++;
        }
        return $arr_return;
    }
    function render_img(){
        $arr_return = array();
        $i=0;
        while($row = mysql_fetch_assoc($this->result)){
            $arr_return[$i] = $row;
            $i++;
        }
        return $arr_return;
    }

}


   
    
?>

